package top.ryw.ssm2.exception;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 全局异常处理器
 */
public class GlobalExceptionResolver implements HandlerExceptionResolver {
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
       // e.printStackTrace();
        System.out.println("===================================================");
        ModelAndView mav = new ModelAndView();
         mav.addObject("msg", e.getMessage());
        mav.setViewName("error");
        return mav;
    }
}
